/**
 * Created by abdulazizalonizi on 8/8/17.
 */
public class Student {

    private String name;
    private double totalScore;
    private int numberOfQuizzes;
    private String quizlist = "";

    public Student(String name , double totalScore , int numberOfQuizzes)
    {
        if ( name ==null | (name.length()==0)  )
            throw new IllegalArgumentException("error:String is empty ");

        this.name = name;
        this.totalScore= totalScore;
        this.numberOfQuizzes = numberOfQuizzes;

    }
    public Student(String name)
    {
        this(name , 0 ,0);

    }

    public Student(String name , double Score)
    {
        this(name , Score , 1);
    }

    public Student(double Score , String name)
    {
        this(name , Score);
    }

    public Student(Student other)
    {
        this(other.name , other.totalScore , other.numberOfQuizzes);
    }

    public String getName()
    {
        return this.name;
    }

    public double getAverage()
    {
     if (this.numberOfQuizzes==0)
         return 0 ;
     return this.totalScore/this.numberOfQuizzes;

    }//this should return zero if no quiz has been taken.

    public double getTotalScore(){
        return this.totalScore;
    }

    public void addQuiz(double score)
    {
        if (score <0)
            throw new IllegalArgumentException("Error: wrong score !");
        this.numberOfQuizzes++;
        this.totalScore +=score ;
    }

    public String toString()
    {
        return "Name: " +this.name+ " ,TotalScore :"+this.totalScore+" ,NumberOfQuizes :"+ this.numberOfQuizzes;
    }

    public boolean equals(Object other)
    {
        if (other instanceof Student)
        {
            Student otherStudent = (Student) other ;
            if (otherStudent.name == this.name & otherStudent.totalScore == this.totalScore & otherStudent.numberOfQuizzes == this.numberOfQuizzes)
            {
                return true ;
            }
            else
                return false ;
        }else
        {
            throw new IllegalArgumentException("Error :not same type argument!");
        }
    }


}
